﻿using System;
using System.Collections.Generic;
using System.IO;
using AdvancedTool.Standard;

namespace DiskToolSDK
{
    /// <summary>
    /// 核心组件类型
    /// </summary>
    public enum CoreType
    {
        /// <summary>
        /// 设置类型组件
        /// </summary>
        Setting,
        /// <summary>
        /// 功能类型组件
        /// </summary>
        Feature
    }
    /// <summary>
    /// 核心组件基类
    /// </summary>
    public abstract class CoreBase
    {

        /// <summary>
        /// 通用基础用户交互组件
        /// </summary>
        public abstract IUserInterface UserInterface
        {
            get;
        }
        /// <summary>
        /// 简介
        /// </summary>
        public abstract string Introduce
        {
            get;
        }
        /// <summary>
        /// 组件名
        /// </summary>
        public abstract string Title
        {
            get;
        }
        /// <summary>
        /// 组件类型
        /// </summary>
        public abstract CoreType Type
        {
            get;
        }
        /// <summary>
        /// 程序启动之前运行
        /// </summary>
        public virtual void Pre_Do()
        {
        }
        /// <summary>
        /// 主要功能
        /// </summary>
        public abstract void Function();
    }

    /// <summary>
    /// 通用用户交互接口，方便开发转换
    /// </summary>
    public interface IUserInterface
    {
        /// <summary>
        /// 自定义参数输出
        /// </summary>
        /// <param name="objs"></param>
        public void RequestCustomOutPut(params Object[] objs);
        /// <summary>
        /// 输出文字
        /// </summary>
        /// <param name="text">待输出的文字</param>
        public void RequestOutPut(string text);
        /// <summary>
        /// 请求用户输入范围内的整数
        /// </summary>
        /// <param name="min">最小数</param>
        /// <param name="max">最大数</param>
        /// <returns></returns>
        public int RequestIntInput(int min, int max);
        /// <summary>
        /// 请求用户输入范围内的数字
        /// </summary>
        /// <param name="min">最小数</param>
        /// <param name="max">最大数</param>
        /// <returns></returns>
        public double RequestNumberInput(double min, double max);
        /// <summary>
        /// 请求用户输入一串字符串
        /// </summary>
        /// <returns></returns>
        public string RequestTextInput();
        /// <summary>
        /// 后期开发备用自定用户输入
        /// </summary>
        /// <param name="args">自定参数</param>
        /// <returns></returns>
        public Object RequestCustomInput(params Object[] args);


    }

    /// <summary>
    /// 功能作者信息属性类。
    /// </summary>
    public class CreatorAttribute : Attribute
    {
        /// <summary>
        /// 作者信息
        /// </summary>
        public string Creator
        {
            get;
            private set;
        }
        /// <summary>
        /// 是否可用，false则用户无法使用该属性注释的功能，true则可用
        /// </summary>
        public bool IsFinish
        {
            get;
            private set;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="creator">作者名</param>
        /// <param name="isFinish">是否可用</param>
        public CreatorAttribute(string creator, bool isFinish = true)
        {
            Creator = creator;
            IsFinish = isFinish;
        }
    }

    public enum ProcessingType
    {
        File, Folder, Both
    }

    /// <summary>
    /// 文件处理的抽象类
    /// </summary>
    public abstract class IFileDoing
    {
        /// <summary>
        /// 功能介绍
        /// </summary>
        public abstract string About
        {
            get;
        }


        /// <summary>
        /// 支持处理的类型，文件/文件夹/皆可
        /// </summary>
        public virtual ProcessingType SupportType
        {
            get => ProcessingType.Both;
        }

        /// <summary>
        /// 限定处理指定后缀的文件后缀，类似“.dll”/“.jpg”
        /// </summary>
        public abstract string[] FileExtends
        {
            get;
        }
        /// <summary>
        /// 启动查找前，对本类功能的前期预设，如允许用户输入以配置功能
        /// </summary>
        public virtual void Init()
        {

        }

        /// <summary>
        /// 遍历文件结束时
        /// </summary>
        public virtual void End()
        {
            System.Console.WriteLine("Done");
        }
        /// <summary>
        /// 文件处理的函数
        /// </summary>
        /// <param name="file">需要处理的文件</param>
        public abstract void FileHandle(FileInfo file);
        /// <summary>
        /// 是否启用特定的后缀文件查找，false即全文件处理，True即只处理指定后缀名的文件
        /// </summary>
        public abstract bool UseExtend
        {
            get;
        }

    }
}
